require('../models/build_cfg.js');
var _            = require('lodash');
var mongoose  = require('mongoose');
var BuildConfig = mongoose.model('BuildConfig');

exports.addBuildConfig = function(config_info,cb){
    var config = new BuildConfig(config_info);
    config.save(cb);
};

exports.deleteBuildConfigs = function(config_ids,cb){
    BuildConfig.remove({_id:{ $in: config_ids}},cb);
};
exports.deleteBuildConfig = function(config_id, cb){
    BuildConfig.remove({_id:config_id}, cb);
};

exports.getBuildConfig = function(config_id,cb){
    BuildConfig.findOne({'_id':config_id},cb);
};

exports.editBuildConfig = function(config_id,config_info,cb){
    BuildConfig.update({_id:config_id},{ name:config_info.name,
        title:config_info.title,
        product_configs:config_info.product_configs,
        projects:config_info.projects,
        type:config_info.type,
        extend_info:config_info.extend_info}, cb);

};
